package com.chagee.store.operation.server.model.bo;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @Author : hk
 * @Date : 2024/12/24
 */
public class EmailConfigItem implements Serializable {

	/**
	 * 配置类型
	 */
	private String type;

	/**
	 * 发件人
	 */
	private String sender;

	/**
	 * 邮件内容
	 */
	private EmailContent content;

	/**
	 * 接受人配置
	 * {"group: {"personal":["a@chagee.com"]}, "subCompany: {dept: ["SUB_COMPANY_SERVER_BOOS", "SUB_COMPANY_BOOS"]}}
	 */
	private String receiverConfig;

	/**
	 * 黑名单
	 */
	private String blankList;


	public EmailConfigItem() {

	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public EmailContent getContent() {
		return content;
	}

	public void setContent(EmailContent content) {
		this.content = content;
	}

	public String getReceiverConfig() {
		return receiverConfig;
	}

	public void setReceiverConfig(String receiverConfig) {
		this.receiverConfig = receiverConfig;
	}

	public boolean supports(String type) {
		return StringUtils.equals(type, this.type);
	}

	public String getBlankList() {
		return blankList;
	}

	public void setBlankList(String blankList) {
		this.blankList = blankList;
	}

	/**
	 * 校验邮件在黑名单当中
	 * @param email
	 * @return
	 */
	public boolean notInBlankList(String email) {
		if (StringUtils.isBlank(blankList)) {
			return true;
		}
		return !blankList.contains(email);
	}
}
